package com.rd.student.dashuju.zhengchengxiang.Day0801;

import java.util.Arrays;

public class Demo01 {
    public static void main(String[] args) {
        move();
        delete();
    }

    public static void move() {
        int[] arr = {1, 3, 5, 7, 9, 11, 13, 15, 17, 0};
        // 插入数字后的有效数字长度
        int[] arr1 = new int[arr.length];
        // 插入的数字
        int digit = 10;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]>digit){
                System.arraycopy(arr,0,arr1,0,i);
                System.arraycopy(arr,i,arr1,i+1,9-i);
                arr1[i]=digit;
                break;
            }
        }
        System.out.println(Arrays.toString(arr1));
    }
    public static void delete(){
        int[] arr = {1, 3, 5, 7, 9, 11, 13, 15, 17, 0};
        // 删除一个的有效数字长度
        int[] arr1 = new int[arr.length-2];

        // 删除的数字
        int digit = 11;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i]==digit){
                System.arraycopy(arr,0,arr1,0,i);
                System.arraycopy(arr,i+1,arr1,i,9-(i+1));
                break;
            }
        }
        System.out.println(Arrays.toString(arr1));
    }
}
